package no.ntnu.fp.exceptions;

import no.ntnu.fp.handler.Handler;
import no.ntnu.fp.messages.MessageCode;


/**
 * Exception to be thrown if {@link no.ntnu.fp.connection.MessageHandler} cannot find a 
 * {@link Handler} for a given {@link MessageCode}.
 * @author benjamin
 *
 */
public class UnsupportedMessageException extends UnsupportedOperationException {
	private final MessageCode messageCode;

	public UnsupportedMessageException(MessageCode messageCode) {
		this.messageCode = messageCode;
	}
	
	public UnsupportedMessageException(String errorMessage, MessageCode messageCode) {
		super(errorMessage);
		this.messageCode = messageCode;
	}
	
	public MessageCode getMessageCode() {
		return messageCode;
	}

	@Override
	public String getLocalizedMessage() {
		return String.format("Unsupported message code: %s\n", messageCode);
	}
	
	/**
	 * Default SUID
	 */
	private static final long serialVersionUID = 1L;
}
